<?php
/*
Primary Author: Zend
Index controller skeleton as defined by framework. 
No controller action is needed, but controller must exist.
*/

class IndexController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
    	$auth = Zend_Auth::getInstance();
    	if(!$auth->hasIdentity()){
    		$type = 'NOLOGIN'; // logged out
    		$name="";
    	}else{
    		$loggedOut = false;
    		$identity = $auth->getIdentity();//identity used for user type/rank decisions
    		$userID = $identity->getUID();
    		if($identity->getUserType() == 'student' ){
    			$type = 'STUDENT';
    			$model = new Application_Model_DbTable_Students();
    			$data = $model->getStudent('ID = '.$userID);
    			$name=$data['FIRSTNAME'];
    		}
    		else if($identity->getUserType() == 'teacher'){
    			$type = 'FACULTY';
    			$model = new Application_Model_DbTable_Teachers();
    			$data = $model->getTeacher('ID = '.$userID);
    			$name=$data['FIRSTNAME'];;
    		}
    		else if($identity->getUserType() == 'organization'){
    			$type = 'PARTNER';
    			$model = new Application_Model_DbTable_Organizations();
    			$data = $model->getOrganization('ID = '.$userID);
    			$name=$data['NAME'];
    		}
    		else{
    			$type = 'NOLOGIN';//default case
    			$name="";
    		}
    		if($identity->getUserRank() >= 2){
    			$type = 'ADMIN';
    		}
    	}
    	$announceTable = new Application_Model_DbTable_Announcements();
    	$announcement = $announceTable->getAnnouncement($type);
		$this->view->announcement = $announcement;
		$this->view->username = $name;
    }

    public function loginAction()
    {
        // action body
    }


}









